using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace MatrixFramework.Shared.Domain.Photos.Search
{
    /// <summary>
    /// 照片搜索领域实体
    /// 支持多维度、智能化的照片搜索功能
    /// </summary>
    public class PhotoSearch : FullAuditedEntity<Guid>, IMultiTenant
    {
        /// <summary>
        /// 租户ID
        /// </summary>
        public virtual Guid? TenantId { get; protected set; }

        /// <summary>
        /// 搜索查询文本
        /// </summary>
        [Required]
        [MaxLength(1000)]
        public virtual string Query { get; protected set; }

        /// <summary>
        /// 搜索类型
        /// </summary>
        public virtual SearchType SearchType { get; protected set; }

        /// <summary>
        /// 搜索条件
        /// </summary>
        public virtual SearchCriteria Criteria { get; protected set; }

        /// <summary>
        /// 搜索过滤器
        /// </summary>
        public virtual List<SearchFilter> Filters { get; protected set; }

        /// <summary>
        /// 排序配置
        /// </summary>
        public virtual SearchSort Sort { get; protected set; }

        /// <summary>
        /// 分页配置
        /// </summary>
        public virtual SearchPagination Pagination { get; protected set; }

        /// <summary>
        /// 搜索结果数量
        /// </summary>
        public virtual int ResultCount { get; protected set; }

        /// <summary>
        /// 总结果数量
        /// </summary>
        public virtual int TotalCount { get; protected set; }

        /// <summary>
        /// 搜索耗时（毫秒）
        /// </summary>
        public virtual long Duration { get; protected set; }

        /// <summary>
        /// 搜索状态
        /// </summary>
        public virtual SearchStatus Status { get; protected set; }

        /// <summary>
        /// 搜索发起者ID
        /// </summary>
        public virtual Guid? UserId { get; protected set; }

        /// <summary>
        /// 搜索发起者名称
        /// </summary>
        [MaxLength(200)]
        public virtual string UserName { get; protected set; }

        /// <summary>
        /// 搜索IP地址
        /// </summary>
        [MaxLength(45)]
        public virtual string IPAddress { get; protected set; }

        /// <summary>
        /// 用户代理
        /// </summary>
        [MaxLength(500)]
        public virtual string UserAgent { get; protected set; }

        /// <summary>
        /// 搜索会话ID
        /// </summary>
        public virtual Guid? SessionId { get; protected set; }

        /// <summary>
        /// 搜索引擎版本
        /// </summary>
        [MaxLength(50)]
        public virtual string EngineVersion { get; protected set; }

        /// <summary>
        /// 搜索元数据
        /// </summary>
        public virtual Dictionary<string, object> Metadata { get; protected set; }

        /// <summary>
        /// 搜索性能统计
        /// </summary>
        public virtual SearchPerformance Performance { get; protected set; }

        /// <summary>
        /// 搜索结果快照（用于缓存和分析）
        /// </summary>
        public virtual List<PhotoSearchResult> Results { get; protected set; }

        /// <summary>
        /// 搜索建议
        /// </summary>
        public virtual List<SearchSuggestion> Suggestions { get; protected set; }

        /// <summary>
        /// 搜索修正记录
        /// </summary>
        public virtual List<SearchCorrection> Corrections { get; protected set; }

        protected PhotoSearch()
        {
            Criteria = new SearchCriteria();
            Filters = new List<SearchFilter>();
            Sort = new SearchSort();
            Pagination = new SearchPagination();
            Metadata = new Dictionary<string, object>();
            Performance = new SearchPerformance();
            Results = new List<PhotoSearchResult>();
            Suggestions = new List<SearchSuggestion>();
            Corrections = new List<SearchCorrection>();
        }

        public PhotoSearch(
            Guid id,
            string query,
            SearchType searchType,
            Guid? userId = null,
            string userName = null,
            Guid? tenantId = null) : base(id)
        {
            Query = query;
            SearchType = searchType;
            UserId = userId;
            UserName = userName;
            TenantId = tenantId;
            Status = SearchStatus.Pending;

            Criteria = new SearchCriteria();
            Filters = new List<SearchFilter>();
            Sort = new SearchSort();
            Pagination = new SearchPagination();
            Metadata = new Dictionary<string, object>();
            Performance = new SearchPerformance();
            Results = new List<PhotoSearchResult>();
            Suggestions = new List<SearchSuggestion>();
            Corrections = new List<SearchCorrection>();
        }

        /// <summary>
        /// 开始搜索
        /// </summary>
        public virtual void StartSearch()
        {
            Status = SearchStatus.Running;
            Performance.StartTime = DateTime.Now;
        }

        /// <summary>
        /// 完成搜索
        /// </summary>
        public virtual void CompleteSearch(int resultCount, int totalCount)
        {
            Status = SearchStatus.Completed;
            ResultCount = resultCount;
            TotalCount = totalCount;
            Performance.EndTime = DateTime.Now;
            Duration = Performance.CalculateDuration();
        }

        /// <summary>
        /// 搜索失败
        /// </summary>
        public virtual void FailSearch(string errorMessage)
        {
            Status = SearchStatus.Failed;
            Metadata["ErrorMessage"] = errorMessage;
            Performance.EndTime = DateTime.Now;
            Duration = Performance.CalculateDuration();
        }

        /// <summary>
        /// 取消搜索
        /// </summary>
        public virtual void CancelSearch()
        {
            Status = SearchStatus.Cancelled;
            Performance.EndTime = DateTime.Now;
            Duration = Performance.CalculateDuration();
        }

        /// <summary>
        /// 更新搜索条件
        /// </summary>
        public virtual void UpdateCriteria(SearchCriteria criteria)
        {
            Criteria = criteria ?? new SearchCriteria();
        }

        /// <summary>
        /// 添加过滤器
        /// </summary>
        public virtual void AddFilter(SearchFilter filter)
        {
            if (filter != null)
            {
                Filters.Add(filter);
            }
        }

        /// <summary>
        /// 移除过滤器
        /// </summary>
        public virtual void RemoveFilter(Guid filterId)
        {
            Filters.RemoveAll(f => f.Id == filterId);
        }

        /// <summary>
        /// 清除所有过滤器
        /// </summary>
        public virtual void ClearFilters()
        {
            Filters.Clear();
        }

        /// <summary>
        /// 更新排序配置
        /// </summary>
        public virtual void UpdateSort(SearchSort sort)
        {
            Sort = sort ?? new SearchSort();
        }

        /// <summary>
        /// 更新分页配置
        /// </summary>
        public virtual void UpdatePagination(SearchPagination pagination)
        {
            Pagination = pagination ?? new SearchPagination();
        }

        /// <summary>
        /// 添加搜索结果
        /// </summary>
        public virtual void AddResult(PhotoSearchResult result)
        {
            if (result != null)
            {
                Results.Add(result);
            }
        }

        /// <summary>
        /// 清除搜索结果
        /// </summary>
        public virtual void ClearResults()
        {
            Results.Clear();
        }

        /// <summary>
        /// 添加搜索建议
        /// </summary>
        public virtual void AddSuggestion(SearchSuggestion suggestion)
        {
            if (suggestion != null)
            {
                Suggestions.Add(suggestion);
            }
        }

        /// <summary>
        /// 添加搜索修正
        /// </summary>
        public virtual void AddCorrection(SearchCorrection correction)
        {
            if (correction != null)
            {
                Corrections.Add(correction);
            }
        }

        /// <summary>
        /// 更新性能统计
        /// </summary>
        public virtual void UpdatePerformance(SearchPerformance performance)
        {
            Performance = performance ?? new SearchPerformance();
        }

        /// <summary>
        /// 设置元数据
        /// </summary>
        public virtual void SetMetadata(string key, object value)
        {
            Metadata[key] = value;
        }

        /// <summary>
        /// 检查搜索是否完成
        /// </summary>
        public virtual bool IsCompleted => Status == SearchStatus.Completed;

        /// <summary>
        /// 检查搜索是否失败
        /// </summary>
        public virtual bool IsFailed => Status == SearchStatus.Failed;

        /// <summary>
        /// 检查搜索是否正在运行
        /// </summary>
        public virtual bool IsRunning => Status == SearchStatus.Running;

        /// <summary>
        /// 获取搜索成功率
        /// </summary>
        public virtual double GetSuccessRate()
        {
            return TotalCount > 0 ? (double)ResultCount / TotalCount : 0;
        }
    }

    /// <summary>
    /// 搜索类型枚举
    /// </summary>
    public enum SearchType
    {
        /// <summary>
        /// 全文搜索
        /// </summary>
        FullText = 0,

        /// <summary>
        /// 标签搜索
        /// </summary>
        Tags = 1,

        /// <summary>
        /// 元数据搜索
        /// </summary>
        Metadata = 2,

        /// <summary>
        /// 相似图片搜索
        /// </summary>
        SimilarImage = 3,

        /// <summary>
        /// 颜色搜索
        /// </summary>
        Color = 4,

        /// <summary>
        /// 地理位置搜索
        /// </summary>
        Location = 5,

        /// <summary>
        /// 时间范围搜索
        /// </summary>
        TimeRange = 6,

        /// <summary>
        /// 人物搜索
        /// </summary>
        Person = 7,

        /// <summary>
        /// 场景搜索
        /// </summary>
        Scene = 8,

        /// <summary>
        /// 物体搜索
        /// </summary>
        Object = 9,

        /// <summary>
        /// 复合搜索
        /// </summary>
        Combined = 10,

        /// <summary>
        /// 语音搜索
        /// </summary>
        Voice = 11,

        /// <summary>
        /// 手势搜索
        /// </summary>
        Gesture = 12,

        /// <summary>
        /// 智能搜索
        /// </summary>
        Intelligent = 13
    }

    /// <summary>
    /// 搜索状态枚举
    /// </summary>
    public enum SearchStatus
    {
        /// <summary>
        /// 等待中
        /// </summary>
        Pending = 0,

        /// <summary>
        /// 运行中
        /// </summary>
        Running = 1,

        /// <summary>
        /// 已完成
        /// </summary>
        Completed = 2,

        /// <summary>
        /// 失败
        /// </summary>
        Failed = 3,

        /// <summary>
        /// 已取消
        /// </summary>
        Cancelled = 4,

        /// <summary>
        /// 超时
        /// </summary>
        Timeout = 5
    }

    /// <summary>
    /// 搜索条件
    /// </summary>
    public class SearchCriteria
    {
        /// <summary>
        /// 关键词列表
        /// </summary>
        public List<string> Keywords { get; set; } = new();

        /// <summary>
        /// 排除关键词
        /// </summary>
        public List<string> ExcludeKeywords { get; set; } = new();

        /// <summary>
        /// 必须包含的关键词
        /// </summary>
        public List<string> MustIncludeKeywords { get; set; } = new();

        /// <summary>
        /// 短语搜索
        /// </summary>
        public List<string> Phrases { get; set; } = new();

        /// <summary>
        /// 正则表达式
        /// </summary>
        public List<string> RegularExpressions { get; set; } = new();

        /// <summary>
        /// 同义词匹配
        /// </summary>
        public bool EnableSynonyms { get; set; } = true;

        /// <summary>
        /// 模糊匹配
        /// </summary>
        public bool EnableFuzzyMatching { get; set; } = true;

        /// <summary>
        /// 模糊阈值
        /// </summary>
        public double FuzzyThreshold { get; set; } = 0.8;

        /// <summary>
        /// 语义搜索
        /// </summary>
        public bool EnableSemanticSearch { get; set; } = false;

        /// <summary>
        /// 搜索范围
        /// </summary>
        public SearchScope Scope { get; set; } = SearchScope.All;

        /// <summary>
        /// 搜索深度
        /// </summary>
        public int SearchDepth { get; set; } = 3;

        /// <summary>
        /// 最大结果数量
        /// </summary>
        public int MaxResults { get; set; } = 100;

        /// <summary>
        /// 搜索超时时间（秒）
        /// </summary>
        public int TimeoutSeconds { get; set; } = 30;

        /// <summary>
        /// 是否启用缓存
        /// </summary>
        public bool EnableCache { get; set; } = true;

        /// <summary>
        /// 缓存有效期（分钟）
        /// </summary>
        public int CacheExpiryMinutes { get; set; } = 60;
    }

    /// <summary>
    /// 搜索范围枚举
    /// </summary>
    public enum SearchScope
    {
        /// <summary>
        /// 全部
        /// </summary>
        All = 0,

        /// <summary>
        /// 仅标题
        /// </summary>
        TitleOnly = 1,

        /// <summary>
        /// 仅描述
        /// </summary>
        DescriptionOnly = 2,

        /// <summary>
        /// 仅标签
        /// </summary>
        TagsOnly = 3,

        /// <summary>
        /// 仅元数据
        /// </summary>
        MetadataOnly = 4,

        /// <summary>
        /// 仅文件名
        /// </summary>
        FileNameOnly = 5,

        /// <summary>
        /// 自定义范围
        /// </summary>
        Custom = 6
    }

    /// <summary>
    /// 搜索过滤器
    /// </summary>
    public class SearchFilter : FullAuditedEntity<Guid>
    {
        /// <summary>
        /// 过滤器类型
        /// </summary>
        public FilterType Type { get; set; }

        /// <summary>
        /// 过滤器字段
        /// </summary>
        public string Field { get; set; }

        /// <summary>
        /// 操作符
        /// </summary>
        public FilterOperator Operator { get; set; }

        /// <summary>
        /// 过滤值
        /// </summary>
        public object Value { get; set; }

        /// <summary>
        /// 过滤器参数
        /// </summary>
        public Dictionary<string, object> Parameters { get; set; } = new();

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnabled { get; set; } = true;

        /// <summary>
        /// 优先级
        /// </summary>
        public int Priority { get; set; } = 0;

        /// <summary>
        /// 逻辑关系
        /// </summary>
        public FilterLogic Logic { get; set; } = FilterLogic.And;
    }

    /// <summary>
    /// 过滤器类型枚举
    /// </summary>
    public enum FilterType
    {
        /// <summary>
        /// 文本过滤器
        /// </summary>
        Text = 0,

        /// <summary>
        /// 数值过滤器
        /// </summary>
        Numeric = 1,

        /// <summary>
        /// 日期过滤器
        /// </summary>
        Date = 2,

        /// <summary>
        /// 布尔过滤器
        /// </summary>
        Boolean = 3,

        /// <summary>
        /// 列表过滤器
        /// </summary>
        List = 4,

        /// <summary>
        /// 地理位置过滤器
        /// </summary>
        Location = 5,

        /// <summary>
        /// 颜色过滤器
        /// </summary>
        Color = 6,

        /// <summary>
        /// 尺寸过滤器
        /// </summary>
        Size = 7,

        /// <summary>
        /// 自定义过滤器
        /// </summary>
        Custom = 8
    }

    /// <summary>
    /// 过滤器操作符枚举
    /// </summary>
    public enum FilterOperator
    {
        /// <summary>
        /// 等于
        /// </summary>
        Equals = 0,

        /// <summary>
        /// 不等于
        /// </summary>
        NotEquals = 1,

        /// <summary>
        /// 包含
        /// </summary>
        Contains = 2,

        /// <summary>
        /// 不包含
        /// </summary>
        NotContains = 3,

        /// <summary>
        /// 开始于
        /// </summary>
        StartsWith = 4,

        /// <summary>
        /// 结束于
        /// </summary>
        EndsWith = 5,

        /// <summary>
        /// 大于
        /// </summary>
        GreaterThan = 6,

        /// <summary>
        /// 大于等于
        /// </summary>
        GreaterThanOrEqual = 7,

        /// <summary>
        /// 小于
        /// </summary>
        LessThan = 8,

        /// <summary>
        /// 小于等于
        /// </summary>
        LessThanOrEqual = 9,

        /// <summary>
        /// 在范围内
        /// </summary>
        InRange = 10,

        /// <summary>
        /// 不在范围内
        /// </summary>
        NotInRange = 11,

        /// <summary>
        /// 在列表中
        /// </summary>
        InList = 12,

        /// <summary>
        /// 不在列表中
        /// </summary>
        NotInList = 13,

        /// <summary>
        /// 为空
        /// </summary>
        IsNull = 14,

        /// <summary>
        /// 不为空
        /// </summary>
        IsNotNull = 15,

        /// <summary>
        /// 正则匹配
        /// </summary>
        Regex = 16
    }

    /// <summary>
    /// 过滤器逻辑枚举
    /// </summary>
    public enum FilterLogic
    {
        /// <summary>
        /// 且
        /// </summary>
        And = 0,

        /// <summary>
        /// 或
        /// </summary>
        Or = 1,

        /// <summary>
        /// 非
        /// </summary>
        Not = 2
    }

    /// <summary>
    /// 搜索排序配置
    /// </summary>
    public class SearchSort
    {
        /// <summary>
        /// 排序字段
        /// </summary>
        public string SortBy { get; set; } = "Relevance";

        /// <summary>
        /// 排序方向
        /// </summary>
        public SortDirection Direction { get; set; } = SortDirection.Descending;

        /// <summary>
        /// 多级排序
        /// </summary>
        public List<SortField> MultiLevelSort { get; set; } = new();

        /// <summary>
        /// 自定义排序函数
        /// </summary>
        public string CustomSortFunction { get; set; }

        /// <summary>
        /// 排序参数
        /// </summary>
        public Dictionary<string, object> SortParameters { get; set; } = new();
    }

    /// <summary>
    /// 排序方向枚举
    /// </summary>
    public enum SortDirection
    {
        /// <summary>
        /// 升序
        /// </summary>
        Ascending = 0,

        /// <summary>
        /// 降序
        /// </summary>
        Descending = 1
    }

    /// <summary>
    /// 排序字段
    /// </summary>
    public class SortField
    {
        /// <summary>
        /// 字段名称
        /// </summary>
        public string FieldName { get; set; }

        /// <summary>
        /// 排序方向
        /// </summary>
        public SortDirection Direction { get; set; }

        /// <summary>
        /// 优先级
        /// </summary>
        public int Priority { get; set; }
    }

    /// <summary>
    /// 搜索分页配置
    /// </summary>
    public class SearchPagination
    {
        /// <summary>
        /// 页码（从1开始）
        /// </summary>
        public int Page { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 20;

        /// <summary>
        /// 跳过的数量
        /// </summary>
        public int Skip => (Page - 1) * PageSize;

        /// <summary>
        /// 最大页面大小
        /// </summary>
        public int MaxPageSize { get; set; } = 100;

        /// <summary>
        /// 是否启用无限滚动
        /// </summary>
        public bool EnableInfiniteScroll { get; set; } = false;

        /// <summary>
        /// 预加载页数
        /// </summary>
        public int PreloadPages { get; set; } = 1;

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling((double)TotalItems / PageSize);

        /// <summary>
        /// 总项目数
        /// </summary>
        public int TotalItems { get; set; }

        /// <summary>
        /// 是否有下一页
        /// </summary>
        public bool HasNextPage => Page < TotalPages;

        /// <summary>
        /// 是否有上一页
        /// </summary>
        public bool HasPreviousPage => Page > 1;
    }

    /// <summary>
    /// 搜索性能统计
    /// </summary>
    public class SearchPerformance
    {
        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime? StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime? EndTime { get; set; }

        /// <summary>
        /// 索引查询耗时（毫秒）
        /// </summary>
        public long IndexQueryDuration { get; set; }

        /// <summary>
        /// 数据库查询耗时（毫秒）
        /// </summary>
        public long DatabaseQueryDuration { get; set; }

        /// <summary>
        /// 缓存查询耗时（毫秒）
        /// </summary>
        public long CacheQueryDuration { get; set; }

        /// <summary>
        /// 排序耗时（毫秒）
        /// </summary>
        public long SortingDuration { get; set; }

        /// <summary>
        /// 过滤耗时（毫秒）
        /// </summary>
        public long FilteringDuration { get; set; }

        /// <summary>
        /// AI处理耗时（毫秒）
        /// </summary>
        public long AIProcessingDuration { get; set; }

        /// <summary>
        /// 内存使用量（字节）
        /// </summary>
        public long MemoryUsage { get; set; }

        /// <summary>
        /// CPU使用率
        /// </summary>
        public double CPUUsage { get; set; }

        /// <summary>
        /// 缓存命中率
        /// </summary>
        public double CacheHitRate { get; set; }

        /// <summary>
        /// 索引使用情况
        /// </summary>
        public List<string> UsedIndexes { get; set; } = new();

        /// <summary>
        /// 性能瓶颈
        /// </summary>
        public List<string> Bottlenecks { get; set; } = new();

        /// <summary>
        /// 计算总耗时
        /// </summary>
        public long CalculateDuration()
        {
            if (!StartTime.HasValue || !EndTime.HasValue)
                return 0;

            return (long)(EndTime.Value - StartTime.Value).TotalMilliseconds;
        }

        /// <summary>
        /// 获取最耗时的操作
        /// </summary>
        public string GetMostTimeConsumingOperation()
        {
            var operations = new Dictionary<string, long>
            {
                ["IndexQuery"] = IndexQueryDuration,
                ["DatabaseQuery"] = DatabaseQueryDuration,
                ["CacheQuery"] = CacheQueryDuration,
                ["Sorting"] = SortingDuration,
                ["Filtering"] = FilteringDuration,
                ["AIProcessing"] = AIProcessingDuration
            };

            return operations.OrderByDescending(kvp => kvp.Value).FirstOrDefault().Key;
        }
    }

    /// <summary>
    /// 照片搜索结果
    /// </summary>
    public class PhotoSearchResult
    {
        /// <summary>
        /// 照片ID
        /// </summary>
        public Guid PhotoId { get; set; }

        /// <summary>
        /// 相关性评分
        /// </summary>
        public double RelevanceScore { get; set; }

        /// <summary>
        /// 匹配高亮
        /// </summary>
        public Dictionary<string, List<string>> Highlights { get; set; } = new();

        /// <summary>
        /// 匹配字段
        /// </summary>
        public List<string> MatchedFields { get; set; } = new();

        /// <summary>
        /// 匹配详情
        /// </summary>
        public Dictionary<string, object> MatchDetails { get; set; } = new();

        /// <summary>
        /// 排名
        /// </summary>
        public int Rank { get; set; }

        /// <summary>
        /// 照片预览信息
        /// </summary>
        public object PhotoPreview { get; set; }
    }

    /// <summary>
    /// 搜索建议
    /// </summary>
    public class SearchSuggestion
    {
        /// <summary>
        /// 建议文本
        /// </summary>
        public string Text { get; set; }

        /// <summary>
        /// 建议类型
        /// </summary>
        public SuggestionType Type { get; set; }

        /// <summary>
        /// 建议评分
        /// </summary>
        public double Score { get; set; }

        /// <summary>
        /// 建议来源
        /// </summary>
        public string Source { get; set; }

        /// <summary>
        /// 建议理由
        /// </summary>
        public string Reason { get; set; }
    }

    /// <summary>
    /// 建议类型枚举
    /// </summary>
    public enum SuggestionType
    {
        /// <summary>
        /// 拼写纠正
        /// </summary>
        SpellingCorrection = 0,

        /// <summary>
        /// 同义词建议
        /// </summary>
        Synonym = 1,

        /// <summary>
        /// 自动完成
        /// </summary>
        AutoCompletion = 2,

        /// <summary>
        /// 相关搜索
        /// </summary>
        RelatedSearch = 3,

        /// <summary>
        /// 热门搜索
        /// </summary>
        PopularSearch = 4,

        /// <summary>
        /// 个性化建议
        /// </summary>
        Personalized = 5,

        /// <summary>
        /// 趋势建议
        /// </summary>
        Trending = 6
    }

    /// <summary>
    /// 搜索修正记录
    /// </summary>
    public class SearchCorrection
    {
        /// <summary>
        /// 原始查询
        /// </summary>
        public string OriginalQuery { get; set; }

        /// <summary>
        /// 修正后查询
        /// </summary>
        public string CorrectedQuery { get; set; }

        /// <summary>
        /// 修正类型
        /// </summary>
        public CorrectionType Type { get; set; }

        /// <summary>
        /// 置信度
        /// </summary>
        public double Confidence { get; set; }

        /// <summary>
        /// 是否被用户接受
        /// </summary>
        public bool IsAccepted { get; set; }

        /// <summary>
        /// 修正详情
        /// </summary>
        public Dictionary<string, object> Details { get; set; } = new();
    }

    /// <summary>
    /// 修正类型枚举
    /// </summary>
    public enum CorrectionType
    {
        /// <summary>
        /// 拼写错误
        /// </summary>
        SpellingError = 0,

        /// <summary>
        /// 语法错误
        /// </summary>
        GrammarError = 1,

        /// <summary>
        /// 词汇建议
        /// </summary>
        VocabularySuggestion = 2,

        /// <summary>
        /// 查询重写
        /// </summary>
        QueryRewrite = 3,

        /// <summary>
        /// 同义词替换
        /// </summary>
        SynonymReplacement = 4,

        /// <summary>
        /// 语义扩展
        /// </summary>
        SemanticExpansion = 5
    }
}